package org.xiaom.butler.service.impl;

import javax.annotation.Resource;
import javax.management.RuntimeErrorException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xiaom.butler.bean.Department;
import org.xiaom.butler.bean.Hotel;
import org.xiaom.butler.dao.DepartmentDao;
import org.xiaom.butler.dao.HotelDao;
import org.xiaom.butler.service.HotelService;
@Service 
public class HotelServiceImpl implements HotelService {
	@Resource
	private HotelDao hotelDao;
	@Resource
	private DepartmentDao departmentDao;
	@Override
	public Hotel get(Integer id) {
		Hotel bean=hotelDao.get(id);
		return bean;
	}
	@Override
	@Transactional
	public void update(Hotel bean) {
		bean =hotelDao.get(1);
		bean.setName("B"+Math.random());
		hotelDao.update(bean);
		
		bean.setVersion((int)(1000*Math.random()));
		hotelDao.update(bean); ;
		throw new RuntimeException();
	} 
	
}
